import { baseUrlConfig } from '@/config/config';
import request from '@/utils/request'

const bastPath = baseUrlConfig.processBaseUrl

export interface LostGoodsAppendItem {
  goodsName: string;
  goodsType: string;
  lostName: string;
  lostPhone: string;
  lostTimeStart: string;
  lostTimeEnd: string;
  timeLimit: number;
  timeLimitUnit: string;
  goodsLimitTime: string;
  lostTerminal: string;
  lostPlace: string;
  files: Array<{
    enclosureContent: string;
    enclosureName: string;
    enclosureSuffix: string;
    resourceAddress: string;
    enclosureCode: string;
  }>
  creator: {
    id: string;
    name: string;
    organId: string;
    organName: string;
  }
}

export interface DisposalGoodsItem {
  lostId: string
  lastMender: {
    id: string
    name: string
    organId: string
    organName: string
  },
}

export interface DynamicLostGoodsItem {
  columns: string
  endLastMenderTime: string
  endTime: string
  goodsName: string
  goodsType: string
  id: number
  lostName: string
  lostPlace: string
  lostTerminal: string
  sign: string
  startLastMenderTime: string
  startTime: string
}

export interface OutBoundItem {
  regId: string
  taskId: string
  taskProcess: string
  creator: {
    id: string
    name: string
    organId: string
    organName: string
  }
}

// 分页查询遗失物品
export const lostGoodsPage = (data: ListParams) => {
  return request({
    url: bastPath + '/lose/goodsLost/find/page',
    method: 'post',
    data
  })
}

// 找回遗失物品
export const retrievedLostGoods = (data: any) => {
  return request({
    url: bastPath + '/lose/goodsLost/retrieved',
    method: 'post',
    data
  })
}

// 新增遗失物品
export const lostGoodsAppend = (data: LostGoodsAppendItem) => {
  return request({
    url: bastPath + '/lose/goodsLost/append',
    method: 'post',
    data
  })
}

// 编辑遗失物品
export const lostGoodsEdit = (data: LostGoodsAppendItem) => {
  return request({
    url: bastPath + '/lose/goodsLost/update',
    method: 'post',
    data
  })
}

// 过期处置
export const disposalLostGoods = (data: DisposalGoodsItem) => {
  return request({
    url: bastPath + '/lose/goodsLost/disposal',
    method: 'post',
    data
  })
}

// 遗失物品详情
export const lostGoodsDetail = (id: string) => {
  return request({
    url: bastPath + '/lose/goodsLost/detail',
    method: 'post',
    data: { lostId: id }
  })
}

// 申请出库
export const appllyOutbound = (data: OutBoundItem) => {
  return request({
    url: bastPath + '/lose/goodsLost/outbound',
    method: 'post',
    data
  })
}

// 领取遗失物品
export const receiveLostGoods = (data: any) => {
  return request({
    url: bastPath + '/lose/goodsLost/receive',
    method: 'post',
    data
  })
}
